﻿using Autofac;
using Quick.Common.Autofac;
using Quick.Common.Components;

namespace Quick.Common
{
    /// <summary>ENode configuration class Autofac extensions.
    /// </summary>
    public static class ConfigurationExtensions
    {
        /// <summary>
        /// Use Autofac as the object container.
        /// 使用autofac为对象的容器。
        /// </summary>
        /// <returns></returns>
        public static Configuration UseAutofac(this Configuration configuration)
        {
            return UseAutofac(configuration, new ContainerBuilder());
        }

        /// <summary>
        /// Use Autofac as the object container.
        /// 使用autofac为对象的容器。
        /// </summary>
        /// <returns></returns>
        public static Configuration UseAutofac(this Configuration configuration, ContainerBuilder containerBuilder)
        {
            ObjectContainer.SetContainer(new AutofacObjectContainer(containerBuilder));
            return configuration;
        }

        /// <summary>
        /// Use Autofac as the object container.
        /// 使用autofac为对象的容器。
        /// </summary>
        /// <returns></returns>
        public static Configuration UseAutofac(this Configuration configuration, IContainer container)
        {
            ObjectContainer.SetContainer(new AutofacObjectContainer(container));
            return configuration;
        }


    }
}
